package com.example.servlet;

import com.example.dao.NovelDao;
import com.example.dao.UserDao;
import com.example.domain.Novel;
import com.example.domain.User;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@WebServlet("/AdminUserSearchServlet")
public class AdminUserSearchServlet extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException{
        request.setCharacterEncoding("utf-8");
        String keyword=request.getParameter("keyword");
        UserDao novelDao=new UserDao();
        List<User> userList=novelDao.getUserBySearchCount(keyword);
        if (userList==null){
            request.setAttribute("msg","获取用户信息失败!");
            request.getRequestDispatcher("admin_index.jsp").forward(request,response);
            return;
        }
        request.setAttribute("userList",userList);
        request.getRequestDispatcher("admin_index.jsp").forward(request,response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException{
        doGet(request,response);
    }
}
